package tenumn.energytech.registrys.pipeline;

import java.util.HashMap;

public class FloatMultiSet<T> {
    private HashMap<T,Float> innerMap=new HashMap<>();
    public float count(T in){
        return innerMap.containsKey(in)?innerMap.get(in):0;
    }
    public float add(T in,float size){
        float result;
        float last;
        if(innerMap.containsKey(in))result= innerMap.get(in);
        else {
            result = 0;
        }
        last=result;
        result=result+size;
        if(result<0)result=0;
        innerMap.put(in,result);
       return last;
    }
    public float remove(T in,float size){
        float result;
        float last;
        if(innerMap.containsKey(in))result= innerMap.get(in);
        else {
            result = 0;
        }
        last=result;
        result=result-size;
        if(result<0)result=0;
        innerMap.put(in,result);
        return last;
    }
}
